home *** CD-ROM | disk | FTP | other *** search
/ Animation How-To / Animation How-to CD.iso / PLY / CHAPTER4 / JELLYDIM / DIAMOVE.BAS < prev    next >
BASIC Source File  |  1994-01-01  |  6KB  |  285 lines

  1. ' Jellyfish Diamond Data File Generator
  2. ' (c) Jeff Bowermaster, 1992
  3.  
  4. TYPE vector
  5.   x AS SINGLE
  6.   y AS SINGLE
  7.   z AS SINGLE
  8. END TYPE
  9.  
  10. pi = 3.1415926536#
  11. radians = 180 / pi
  12.  
  13. DIM vertex(42) AS vector, triangle(3) AS vector
  14. DIM red(16), green(16), blue(16)
  15.  
  16. ' set the screen up with pretty rainbow colors
  17.  
  18. SCREEN 12
  19.  
  20. scale = .015
  21. xoff = 320
  22. yoff = 240
  23.  
  24. WINDOW ((0 - xoff) * scale, (0 - yoff) * scale)-((639 - xoff) * scale, (479 - yoff) * scale)
  25.  
  26. FOR y = 1 TO 4
  27.     FOR x = 1 TO 4
  28.          colornum = x + ((y - 1) * 4) - 1
  29.          READ red(colornum), green(colornum), blue(colornum)
  30.          KOLOR = 65536 * blue(colornum) + 256 * green(colornum) + red(colornum)
  31.          PALETTE colornum, KOLOR
  32.          COLOR colornum
  33.     NEXT x
  34. NEXT y
  35.  
  36.  
  37. 'Rainbow Palette
  38.  
  39. DATA  0,  0,  0
  40. DATA 32,  0,  0
  41. DATA 42,  0,  0
  42. DATA 58, 16,  0
  43. DATA 63, 32,  0
  44. DATA 58, 56,  0
  45. DATA 16, 42,  0
  46. DATA  0, 30, 36
  47. DATA  0, 20, 40
  48. DATA  0, 10, 48
  49. DATA  0,  0, 63
  50. DATA 20,  0, 53
  51. DATA 23,  0, 29
  52. DATA 19,  7, 17
  53. DATA 50, 40, 45
  54. DATA 63, 63, 63
  55.  
  56. pi = 3.1415926535#
  57. rad = pi / 180
  58.  
  59. radius1 = 1
  60. radius2 = 1.4
  61. radius3 = 1.8
  62. radius4 = .7
  63. radius5 = .01
  64.  
  65. ht1 = 1
  66. ht2 = .8
  67. ht3 = .5
  68. ht4 = -1
  69. ht5 = -1.9
  70.  
  71. masteramp = 1.3
  72.  
  73. ampl1 = .03 * masteramp
  74. ampl2 = .02 * masteramp
  75. ampl3 = .01 * masteramp
  76. ampl4 = .04 * masteramp
  77. ampl5 = .05 * masteramp
  78.  
  79. phase = 80   'hump phase
  80.  
  81. phase1 = 0
  82. phase2 = 25
  83. phase3 = 50
  84. phase4 = 75
  85. phase5 = 87
  86.  
  87. aspect = .1  ' control the size of the ellipses in the simplified model
  88. hump = 1.3
  89. wave = 2
  90. DO WHILE INKEY$ = ""
  91. FOR ang = 0 TO 360 STEP 10
  92.  
  93.   height1 = ht1 + ampl1 * (wave * COS(rad * (ang - phase1)) + EXP(hump * (1 + COS((ang - phase - phase1) * rad))))
  94.   height2 = ht2 + ampl2 * (wave * COS(rad * (ang - phase2)) + EXP(hump * (1 + COS((ang - phase - phase2) * rad))))
  95.   height3 = ht3 + ampl3 * (wave * COS(rad * (ang - phase3)) + EXP(hump * (1 + COS((ang - phase - phase3) * rad))))
  96.   height4 = ht4 + ampl4 * (wave * COS(rad * (ang - phase4)) + EXP(hump * (1 + COS((ang - phase - phase4) * rad))))
  97.   height5 = ht5 + ampl5 * (wave * COS(rad * (ang - phase5)) + EXP(hump * (1 + COS((ang - phase - phase5) * rad))))
  98.  
  99.   newradius1 = radius1 * height1
  100.   newradius2 = radius2 * height2 * 1.3
  101.   newradius3 = radius3 * height3 * 2
  102.   newradius4 = radius4 * (1.9 + height4)
  103.   newradius5 = radius5
  104.  
  105. oval = 1
  106. xfactor = 1 / oval
  107. yfactor = oval / 1
  108.  
  109. FOR f = 1 TO 8
  110.   a = 360 * f / 8
  111.  
  112.   vertex(f).x = newradius1 * xfactor * COS(rad * a)
  113.   vertex(f).y = newradius1 * yfactor * SIN(rad * a)
  114.   vertex(f).z = height1
  115.  
  116.   vertex(f + 8).x = newradius2 * xfactor * COS(rad * (a + 22.5))
  117.   vertex(f + 8).y = newradius2 * yfactor * SIN(rad * (a + 22.5))
  118.   vertex(f + 8).z = height2
  119.  
  120.   vertex(f + 16).x = newradius3 * xfactor * COS(rad * (a + 45))
  121.   vertex(f + 16).y = newradius3 * yfactor * SIN(rad * (a + 45))
  122.   vertex(f + 16).z = height3
  123.  
  124.   vertex(f + 24).x = newradius3 * xfactor * COS(rad * (a + 67.5))
  125.   vertex(f + 24).y = newradius3 * yfactor * SIN(rad * (a + 67.5))
  126.   vertex(f + 24).z = height3
  127.  
  128.   vertex(f + 32).x = newradius4 * xfactor * COS(rad * (a + 67.5))
  129.   vertex(f + 32).y = newradius4 * yfactor * SIN(rad * (a + 67.5))
  130.   vertex(f + 32).z = height4
  131.  
  132. NEXT f
  133.  
  134.   vertex(41).x = 0
  135.   vertex(41).y = 0
  136.   vertex(41).z = height5
  137.  
  138.   vertex(42).x = 0
  139.   vertex(42).y = 0
  140.   vertex(42).z = height1
  141.  
  142. ' The triangular faces listed clockwise by vertex
  143.  
  144. 'Crown
  145. eek:
  146. DATA 1,42,2
  147. DATA 2,42,3
  148. DATA 3,42,4
  149. DATA 4,42,5
  150. DATA 5,42,6
  151. DATA 6,42,7
  152. DATA 7,42,8
  153. DATA 8,42,1
  154.  
  155. DATA 1,2,9
  156. DATA 2,3,10
  157. DATA 3,4,11
  158. DATA 4,5,12
  159. DATA 5,6,13
  160. DATA 6,7,14
  161. DATA 7,8,15
  162. DATA 8,1,16
  163.  
  164. DATA 2,17,9
  165. DATA 2,10,17
  166. DATA 3,18,10
  167. DATA 3,11,18
  168. DATA 4,19,11
  169. DATA 4,12,19
  170. DATA 5,20,12
  171. DATA 5,13,20
  172.  
  173. DATA 6,21,13
  174. DATA 6,14,21
  175. DATA 7,22,14
  176. DATA 7,15,22
  177. DATA 8,23,15
  178. DATA 8,16,23
  179. DATA 1,24,16
  180. DATA 1,9,24
  181.  
  182. DATA 10,25,17
  183. DATA 10,18,25
  184. DATA 11,26,18
  185. DATA 11,19,26
  186. DATA 12,27,19
  187. DATA 12,20,27
  188. DATA 13,28,20
  189. DATA 13,21,28
  190.  
  191. DATA 14,29,21
  192. DATA 14,22,29
  193. DATA 15,30,22
  194. DATA 15,23,30
  195. DATA 16,31,23
  196. DATA 16,24,31
  197. DATA 9,32,24
  198. DATA 9,17,32
  199.  
  200. 'Pavilion
  201.  
  202. DATA 17,40,32
  203. DATA 24,32,40
  204. DATA 24,40,39
  205. DATA 24,39,31
  206. DATA 23,31,39
  207. DATA 23,39,38
  208. DATA 23,38,30
  209. DATA 22,30,38
  210.  
  211. DATA 22,38,37
  212. DATA 22,37,29
  213. DATA 21,29,37
  214. DATA 21,37,36
  215. DATA 21,36,28
  216. DATA 20,28,36
  217. DATA 20,36,35
  218. DATA 20,35,27
  219.  
  220. DATA 19,27,35
  221. DATA 19,35,34
  222. DATA 19,34,26
  223. DATA 18,26,34
  224. DATA 18,34,33
  225. DATA 18,33,25
  226. DATA 17,25,33
  227. DATA 17,33,40
  228.  
  229. DATA 40,33,41
  230. DATA 40,41,39
  231. DATA 39,41,38
  232. DATA 38,41,37
  233. DATA 37,41,36
  234. DATA 36,41,35
  235. DATA 35,41,34
  236. DATA 34,41,33
  237.  
  238. xrotate = 0
  239. yrotate = 20
  240. zrotate = 0
  241.  
  242.  
  243. RESTORE eek
  244. FOR i = 1 TO 80
  245.     READ v(1), v(2), v(3)
  246.         FOR t = 1 TO 3
  247.  
  248.         x0 = vertex(v(t)).x
  249.         y0 = vertex(v(t)).y
  250.         z0 = vertex(v(t)).z
  251.  
  252.         X1 = x0
  253.         Y1 = y0 * COS(xrotate / radians) - z0 * SIN(xrotate / radians)
  254.         Z1 = y0 * SIN(xrotate / radians) + z0 * COS(xrotate / radians)
  255.  
  256.         X2 = Z1 * SIN(yrotate / radians) + X1 * COS(yrotate / radians)
  257.         Y2 = Y1
  258.         Z2 = Z1 * COS(yrotate / radians) - X1 * SIN(yrotate / radians)
  259.  
  260.         X3 = X2 * COS(zrotate / radians) - Y2 * SIN(zrotate / radians)
  261.         Y3 = X2 * SIN(zrotate / radians) + Y2 * COS(zrotate / radians)
  262.         z3 = Z2
  263.  
  264.         triangle(t).x = X3
  265.         triangle(t).y = Y3
  266.         triangle(t).z = z3
  267.  
  268.     NEXT t
  269.  
  270.     centerx = (vertex(v(1)).x + vertex(v(2)).x + vertex(v(3)).x) / 3
  271.     centery = (vertex(v(1)).y + vertex(v(2)).y + vertex(v(3)).y) / 3
  272.     centerz = (vertex(v(1)).z + vertex(v(2)).z + vertex(v(3)).z) / 3
  273.  
  274.     c = 16 - ((4 * (centerz / 1)) + 9)     'color code by height
  275.  
  276.     LINE (triangle(1).y, triangle(1).z)-(triangle(2).y, triangle(2).z), 4 + i MOD 4
  277.     LINE (triangle(2).y, triangle(2).z)-(triangle(3).y, triangle(3).z), 4 + i MOD 4
  278.     LINE (triangle(3).y, triangle(3).z)-(triangle(1).y, triangle(1).z), 4 + i MOD 4
  279.  
  280. NEXT i
  281. CLS
  282. NEXT ang
  283. LOOP
  284.  
  285.